'use server';

import { BookNote } from '../types';
import { getBooksByCategory, updateBookNote, getBookById } from '../utils/dynamodb';

export async function fetchBooks(category: string): Promise<BookNote[]> {
  return getBooksByCategory(category);
}

export async function saveBookNote(bookId: string, note: string) {
  return updateBookNote(bookId, note);
}

export async function fetchBookById(id: string): Promise<BookNote> {
  const book = await getBookById(id);
  return {
    id: book.id,
    title: book.title,
    image: book.image,
    note: book.note,
    category: book.category,
    createdAt: book.createdAt,
    updatedAt: book.updatedAt
  };
} 
